package com.api.gbhg.zengping.dao;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;

/**
 * @program: ecology_zp
 * @author: Mr.zeng
 * @create: 2020-12-18 10:48
 **/
public class BaseSwitchDao {
    public static final Logger LOGGER = LoggerFactory.getLogger("gbhg");

    /**
     * 查询基础表
     * @param rs
     * @param tableName
     * @param id
     * @return
     */
    public RecordSet selectById(RecordSet rs,String tableName,String id){
        String sql="select * from "+tableName+" where id=?";
        rs.executeQuery(sql,id);
        LOGGER.info("基础开关表查询sql-------->"+sql);
        return rs;
    }

    /**
     * 修改开关
     * @param rs
     * @param tableName
     * @param value
     * @param id
     */
    public void updateById(RecordSet rs,String tableName,String value,String id){
        if("true".equals(value)){
            value="false";
        }else {
            value="true";
        }
        String sql="UPDATE "+tableName+" SET switch_value=? WHERE id=?";
        LOGGER.info("基础开关表修改sql-------->"+sql);
        rs.executeUpdate(sql,value,id);
    }
}
